package org.lanqiao.tjut.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.tjut.bean.UsersBeanTea;
import org.lanqiao.tjut.service.ServiceFactory;

public class UserTeacher extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("UTF-8");

		UsersBeanTea usersBT = new UsersBeanTea();

		// 根据有隐藏主键判断是否为首次登入
		String teaNum = request.getParameter("userNum");

		if (teaNum == null) {

			// 获取js链接传递的老师number

			String teaNum1 = request.getParameter("Unumber");

			usersBT.setTeanum(teaNum1);

			// 查询老师名下的所有课程

			List<UsersBeanTea> UsersBT = ServiceFactory.getUserInfoManagerTeaServiceInstance().getAllUsersInfo(usersBT);

			request.getSession().setAttribute("lstUsersTea", UsersBT);

			request.removeAttribute("usersB");

			request.getRequestDispatcher("logined/UserInfoManager/userTeacher.jsp").forward(request, response);
		}

		usersBT.setTeanum(teaNum);

		// 查询老师名下的所有课程

		List<UsersBeanTea> UsersBT = ServiceFactory.getUserInfoManagerTeaServiceInstance().getAllUsersInfo(usersBT);

		request.getSession().setAttribute("lstUsersStu", UsersBT);

	

		request.getRequestDispatcher("logined/UserInfoManager/userTeacher.jsp").forward(request, response);

	}

}
